node {
    stage('git chekout') {
        checkout([$class                           : 'GitSCM',
                  branches                         : [[name: "master"]],
                  doGenerateSubmoduleConfigurations: false,
                  extensions                       : [],
                  gitTool                          : 'Default',
                  submoduleCfg                     : [],
                  userRemoteConfigs                : [[url: 'https://gitee.com/fastjrun/demo.git']]
        ])
    }
    stage('parallel package') {
        parallel(
                'package admin': {
                    sh 'cd demo-admin && npm install && npm run build:prod'
                },
                'package server': {
                    sh 'mkdir -p demo-base/src/main/java && mvn clean package -pl demo-server -am -Dbdgc.skip=false'
                }
        )
    }
    stage('docker build & push') {
        sh 'mkdir -p output && rm -rf output/* ' +
                '&& cp demo-server/target/demo-server.jar ./output/app.jar ' +
                '&& cp -r demo-admin/dist ./output ' +
                '&& cp Dockerfile ./output && cp default.conf ./output && cp entrypoint.sh ./output'
        sh 'cd output && docker build . -t fastjrun/demo-all:3.1'
    }
}
